.PHONY= doc clean script

CC=g++
OPTIONS= -g -Wall
DEBUG= #-D DEBUG
LIBDIR=lib
INCLUDEDIR = include
BUILDDIR = build
LIBRARIES = soil
INCLUDE= -I include  -I soil
GRAPHS= -lGL -lGLU -lglut 
_OBJ= camera.o particle.o compositeParticle.o emitter.o particleStorage.o texture.o


BUILDOBJ=$(patsubst %,$(BUILDDIR)/%,$(_OBJ))


main: build  $(BUILDOBJ) ./include/*.hpp ./src/main.cc 
	$(CC) $(OPTIONS) $(DEBUG) $(INCLUDE) src/main.cc $(BUILDDIR)/* -o main $(GRAPHS) 

build:
	mkdir build
	for i in $(LIBRARIES); do \
		cd $$i; \
		make ; \
		cd ..;\
		cp -f $$i/*.o build;\
	done
	
$(BUILDDIR)/%.o: $(LIBDIR)/%.cpp $(INCLUDEDIR)/%.hpp
	$(CC) $(OPTIONS) -c $(INCLUDE) $(DEBUG) -o $@ $<
	
doc:
	doxygen

clean:
	rm -f $(OBJ)
	rm -f main
	rm -rf build
	for i in $(LIBRARIES); do \
		cd $$i; \
		make clean; \
		cd ..;\
	done

script: clean main 
